﻿/*
 * GridBitmapDecoderBase
 * 
 * initial implementation : 20.10.2008
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;
using System.IO;
using System.Collections.Generic;
using System.Windows.Threading;
using System.Windows.Media.Imaging;


namespace Petra.Gis.ImagingServices
{

  /// <summary>
  /// Base class for Grid data decoder
  /// <para>
  /// Horrible implementation because of MSFT paranoia
  /// , where nobody can inherit from System.Windows.Media.Imaging.
  /// This decoder cant be invoked automatically by WPF using BitmapDecoder.
  /// Create functions, instead manual create by constructor is always necessary.
  /// BitmapDecoder is sealed and unable to inherit from.
  /// </para>
  /// </summary>
  public abstract class GridBitmapDecoderBase : DispatcherObject, IGridBitmapDecoder
  {

    protected BitmapCreateOptions _createOptions;
    protected BitmapCacheOption _cacheOption;
    protected Stream _data;




    protected GridBitmapDecoderBase(Stream data, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption)
      :base()
    {
      _createOptions = createOptions;
      _cacheOption = cacheOption;
      _data = data;
    }




    protected GridBitmapDecoderBase(Uri fileUri, BitmapCreateOptions createOptions, BitmapCacheOption cacheOption)
      :base()
    {
      _createOptions = createOptions;
      _cacheOption = cacheOption;
      if (!fileUri.IsFile)
        throw new ArgumentException("invalid URI" + fileUri.ToString());

      _data = new FileStream(fileUri.LocalPath, FileMode.Open, FileAccess.Read);
    }





    public abstract BitmapCodecInfo CodecInfo
    { get; }






    public abstract System.Collections.ObjectModel.ReadOnlyCollection<BitmapFrame> Frames
    { get; }





  }
}
